package regexObject;

import java.util.Arrays;

/**
 * String[] split(String regex):拆分
 * 将当前字符串按照满足正则表达式(regex)的部分进行拆分，将拆分出的以String[]形式返回
 */
public class SplitDemo {
    public static void main(String[] args) {
        String line = "123vsd4214fqwef213120";
        String[] data = line.split("[a-z]+");
        System.out.println(Arrays.toString(data));
        System.out.println("--------------------------------");
        line = "123.123.42";
        data = line.split("\\.");
        //二次转义,\\被转义成\,\.被转义成.;
        System.out.println(Arrays.toString(data));
        System.out.println("--------------------------------");
        line = "123.23..2314.....";
        data = line.split("\\.");
        System.out.println(Arrays.toString(data));
        System.out.println(data.length);
    }
}
